package com.ruoyi.web.controller.common.mapper;

import com.ruoyi.common.core.dao.BaseMapper;
import com.ruoyi.common.entity.DO.CommonImageDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface IBackCommonImageMapper extends BaseMapper<CommonImageDO> {

    @Update("Update common_image SET model_id=#{productId} WHERE model_id=#{modelId}")
    int linkProduct(@Param("productId") Long productId,@Param("modelId") Long modelId);

    /**
     * 根据模块类型和ID删除关联图片
     *
     * @param modelType
     * @param modelId
     * @return
     */
    @Delete("UPDATE common_image SET is_delete=1 WHERE model_type=#{modelType} and model_id=#{modelId}")
    int deleteByTypeAndLinkId(@Param("modelType") Integer modelType,@Param("modelId") Long modelId);


}
